C     PROGRAM KBFIL(INPUT,OUTPUT,TAPE5=INPUT,TAPE6=OUTPUT)

C*******************************************************************************
C
C
C
C     EXECUTIVE PROGRAM FOR KALMAN-BUCY FILTER PROBLEM
C
C
C
C*******************************************************************************
      IMPLICIT REAL*8 (A-H,O-Z)
      DIMENSION A(16),B(8),H(12),Q(16),R(9),ATIL(16),BTIL(8),QTIL(16),F(
     112),P(16),DUMMY(114)
      DIMENSION NA(2),NB(2),NH(2),NQ(2),NR(2),NATIL(2),NBTIL(2),NQTIL(2)
     1,IOP(5),NF(2),NP(2),NDUM(2)
      LOGICAL  IDENT,DISC,NEWT,STABLE,FNULL
C
C
C     INPUT HOLLERITH DATA FOR TITLE OF OUTPUT
      CALL RDTITL
C
C     INPUT COEFFICIENT MATRICES AND NOISE INTENSITIES
C     FOR CONTINUOUS SYSTEM
      CALL READ(5,A,NA,B,NB,H,NH,Q,NQ,R,NR)
C
C     GENERATE COEFFICIENT MATRICES FOR DIGITAL SYSTEM
      IOP(1)=0
      DELT= .05
      N1=(NA(1)**2) + 1
      CALL EXPINT(A,NA,ATIL,NATIL,DUMMY,NA,DELT,IOP,DUMMY(N1))
      CALL MULT(DUMMY,NA,B,NB,BTIL,NBTIL)
      CALL PRNT(ATIL,NATIL,4HATIL,1)
      CALL PRNT(BTIL,NBTIL,4HBTIL,1)
C
C     COMPUTE VARIANCE MATRIX FOR PROCESS NOISE OF DIGITAL SYSTEM
      CALL EQUATE(Q,NQ,QTIL,NQTIL)
      CALL TRANP(A,NA,DUMMY,NDUM)
      IOP(2)= 0
      CALL SAMPL(DUMMY,NDUM,B,NB,QTIL,NQTIL,R,NR,W,NW,DELT,IOP,DUMMY(N1)
     1)
      CALL PRNT(QTIL,NQTIL,4HQTIL,1)
C
C     SOLVE FOR DIGITAL FILTER GAIN
      IDENT = .TRUE.
      DISC  = .TRUE.
      STABLE = .FALSE.
      FNULL  =  .TRUE.
      NEWT   =  .TRUE.
      ALPHA=.5
      IOP(1)=1
      IOP(2)=0
      IOP(3)=0
      IOP(4)=0
      IOP(5)=0
      CALL ASMFIL(ATIL,NATIL,G,NG,H,NH,QTIL,NQTIL,R,NR,F,NF,P,NP,IDENT,
     1DISC,NEWT,STABLE,FNULL,ALPHA,IOP,DUMMY)
C
C
      STOP
      END
      OUTPUT FOR KALMAN-BUCY FILTER PROBLEM
 A         4   4
      -2.6       .25      -38.       0.0
     -.075      -.27       4.4       0.0
      .078      -.99      -.23      .052
        1.      .078       0.0       0.0
 B         4   2
       17.        7.
       .82      -3.2
       0.0      .046
       0.0       0.0
 H         3   4
        1.       0.0       0.0       0.0
       0.0        1.       0.0       0.0
    -.0852    -.0421     -2.24    -.0021
 Q         4   4
        1.       0.0       0.0       0.0
       0.0        1.       0.0       0.0
       0.0       0.0        1.       0.0
       0.0       0.0       0.0        1.
 R         3   3
        1.       0.0       0.0
       0.0        1.       0.0
       0.0       0.0       1.0
